package com.wjv.example.spbt.shiro.service;

import com.wjv.example.spbt.shiro.model.Permission;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>Title: PermissionServiceImpl</p>
 * <p>
 * 角色对应的权限
 *
 * @author wjv
 * @date 2021/7/5 13:16
 */
@Service
public class PermissionServiceImpl {

    private final static List<Permission> PERMISSIONS = new ArrayList<>();

    static {
        PERMISSIONS.add(Permission.of(1, "用户列表", "user:list"));
        PERMISSIONS.add(Permission.of(2, "用户信息", "user:item"));
        PERMISSIONS.add(Permission.of(3, "用户删除", "user:del"));
    }

    public List<Permission> getPermissions(int roleId) {
        List<Permission> collect = PERMISSIONS.stream()
                .filter(p -> p.getId() > 0)
                .collect(Collectors.toList());
        return collect;
    }

}
